package com.yeyks.commonReference.service.hotel.impl;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import com.yeyks.common.exception.ServiceException;
import com.yeyks.commonReference.service.hotel.HotelInfoService;
import com.yeyks.commonReference.service.hotel.HotelSearchBaseService;
import com.yeyks.commonReference.service.hotel.HotelSearchC2bService;
import com.yeyks.commonReference.service.order.OrderPickRecordService;
import com.yeyks.hotel.param.HotelInfoHotelSearchHotelInfoParam;
import com.yeyks.search.pojo.param.search.HotelSearchC2bListParam;
import com.yeyks.search.pojo.vo.search.HotelInfoHotelUnionSearchVo;
import com.yeyks.search.pojo.vo.search.HotelInfoHotelUnionSearchVoHotle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Objects;

@Service
public class HotelSearchBaseServiceImpl implements HotelSearchBaseService {

    @Autowired
    private HotelInfoService hotelInfoService;
    @Autowired
    private HotelSearchC2bService hotelC2bSearchService;
    @Autowired
    private OrderPickRecordService orderPickRecordService;

    //酒店详情:v3.4
    @Override
    public HotelInfoHotelUnionSearchVoHotle hotelSearchHotelInfo(HotelInfoHotelSearchHotelInfoParam param) {
        //修正时间
        param.setStartDate(DateUtil.beginOfDay(param.getStartDate()));
        param.setEndDate(DateUtil.beginOfDay(param.getEndDate()));
        HotelInfoHotelUnionSearchVoHotle hotelInfoHotelUnionSearchVoHotle = null;
        switch (param.getVipFlag()) {
            case 1:
                break;
            case 3:
                break;
            case 2:
                break;
            case 10:
                //v3.6
                HotelSearchC2bListParam hotelSearchC2bListParam = new HotelSearchC2bListParam();
                hotelSearchC2bListParam.setUserId(param.getUserId());
                hotelSearchC2bListParam.setTimestamp(param.getTimestamp());
                hotelSearchC2bListParam.setHotelId(param.getHotelId());
                hotelSearchC2bListParam.setSourceType(param.getSourceType());
                HotelInfoHotelUnionSearchVo hotelInfoHotelUnionSearchVo = hotelC2bSearchService.getGrabTheOrderedHotelList(hotelSearchC2bListParam);
                if (Objects.isNull(hotelInfoHotelUnionSearchVo) || CollectionUtil.isEmpty(hotelInfoHotelUnionSearchVo.getList())) {
                    throw new ServiceException("酒店不存在");
                }
                hotelInfoHotelUnionSearchVoHotle = hotelInfoHotelUnionSearchVo.getList().get(0);
            default:
                break;
        }
        return hotelInfoHotelUnionSearchVoHotle;
    }

}
